#!/bin/bash

#=======================================================================
# ga
# File ID: e89047ce-29d1-11e2-bb6f-00c0a8deee11
#=======================================================================

progname=ga

if test "$1" = "init"; then
    if test -z "$(git config --get annex.uuid)"; then
        git config annex.uuid $(suuid -wa -t ga_init)
    else
        echo $progname: Repository is already initialised for git-annex >&2
        exit 1
    fi
else
    test -z "$(git config --get annex.uuid)" && { echo $progname: annex.uuid is not defined, aborting >&2; exit 1; }
fi

if test "$1" = "sync"; then
    git wait-until-clean -u
fi

if test "$1" = "fsck"; then
    shift
    git-annex fsck "$@" 2>&1 | ga-fsck-size
elif test "$1" = "md"; then
    shift
    git-annex metadata "$@"
else
    git-annex "$@"
fi
